<?php

/**
 * 商户的消费记录
 * User: csyr
 * Date: 6/25/16
 * Time: 15:25
 */

namespace Home\Model;
use Common\Library\Constant;
use Think\Model;

class ConsumeInstallmentHistoryModel extends Model{

    /**
     * 获取分期付款消费还款时间
     * @param array $consume
     * @return int
     */
    public function getRepaymentTime($consume)
    {
        $consumeRepaymentTime = intval($consume['repayment_time']);
        if ($consumeRepaymentTime) {
            for($i=1;$i<=Constant::REPAY_TIMES;$i++)
            {
                $consumeRepaymentTime = D("ConsumeHistory")->getRepaymentTime($i);
                $currentRepaymentTime = strtotime(date('Y-m-' . Constant::BILL_LAST_DAY . ' 00:00:00', time()));
                /*if (time() < $consumeRepaymentTime && time()>$currentRepaymentTime) */
                if (time() < $consumeRepaymentTime )
                {
                    break;
                }
            }
        }
        return $consumeRepaymentTime;
    }
}
